﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SmartSpace.Silverlight
{
    public delegate void SwitchCompletedEventHandler(SlView outView, SlView inView, SwitchDirection direction);
      
    public abstract class SwitchEffect
    {
        public SlView OutView { get; private set; }
        public SlView InView { get; private set; }
        public SwitchDirection Direction { get; private set; }

        public bool IsSwitching { get; private set; }

        public event SwitchCompletedEventHandler SwitchCompleted;

        public void PrepareSwitch(Size containerSize, SlView outView, SlView inView, SwitchDirection direction)
        {
            OutView = outView;
            InView = inView;
            Direction = direction;

            OnPrepareSwitch(containerSize, outView, inView, direction);
        }

        protected abstract void OnPrepareSwitch(Size containerSize, SlView outView, SlView inView, SwitchDirection direction);

        public void Begin()
        {
            IsSwitching = true;
            OnBegin();
        }

        protected abstract void OnBegin();

        /// <summary>
        /// 完成切换
        /// </summary>
        protected void FinishSwitch()
        {
            IsSwitching = false;
            if (SwitchCompleted != null)
            {
                SwitchCompleted(OutView, InView, Direction);
            }
        }


        //public abstract SwitchDirection GetSwitchDirection();

        //public abstract SlView GetOutView();
        //public abstract SlView GetInView();
    }
}
